<!DOCTYPE html>
<html lang="en">
<head>
    <title>功能演示</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- <meta ng-include="'head.html'"> -->
    <style type="text/css">

    </style>
    <script src="../lib/js/jquery.min.js" type="text/javascript"></script>
    <script src="../js/build.js" type="text/javascript"></script>
    <script src="../js/public.js" type="text/javascript"></script>
    <script src="https://webapi.amap.com/js/marker.js"></script>
    <!--<script src="//webapi.amap.com/loca?key=17cc15a8dd6241aa1984495c67d70e6f"></script>`-->
    <script src="https://webapi.amap.com/maps?v=1.4.2&key=17cc15a8dd6241aa1984495c67d70e6f"></script>
</head>
<body class="flat-blue">
<div class="app-container" ng-app="myApp" ng-controller="myCtrl">
    <div class="row content-container">
        <div ng-include="'menus.html'" onload="loadReady()"></div>
        <div class="container-fluid">
            <div class="side-body padding-top" id="main" style="padding-top: 55px;">
                <!------------------Main---------------->
                <div style="min-height:780px" id="view"></div>

                <!------------------End Main---------------------->
            </div>  <!--End side-body-->
        </div>  <!--End container-fluid-->
    </div>  <!--End content-container-->
    <div ng-include="'footer.html'"></div>
</div>  <!--End app-container-->

<script language="javascript">
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope) {
        // loadCtlBase($scope);
    });

    var center = [103.041554, 30.010237];
    var map = new AMap.Map('view',{
        resizeEnable: true, zoom:9,
        center: [center[0] - 0.508, center[1]],
        mapStyle: 'amap://styles/darkblue',
    });
    var marker = new AMap.Marker({
        position: new AMap.LngLat(center[0], center[1]),
        icon: '../img/star.png',
        title: '市政府'
    });
    map.add(marker);




    loadPolygon();

    function loadPolygon(){
        AMap.service('AMap.DistrictSearch', function() {
            var opts = {
                subdistrict: 1,   //返回下一级行政区
                extensions: 'all',  //返回行政区边界坐标组等具体信息
                level: 'city'  //查询行政级别为 市
            };
            var district = new AMap.DistrictSearch(opts);
            search('雅安市', 1);
            function search(name, level){
                district.search(name, function(status, result) {
                    var bounds = result.districtList[0].boundaries;
                    if (bounds) deawLine(bounds, level);
                    if(level==1){
                        result.districtList[0].districtList.forEach(function(d){
                            //search(d.name, 2);
                        });
                    }
                    map.setFitView(true);
                });
            }
        });

    }

    function deawLine(bounds, level){
        for (var i = 0, l = bounds.length; i < l; i++) {
            var polygon = new AMap.Polygon({
                map: map,
                strokeWeight: level>1 ? 0.2 : 1,
                path: bounds[i],
                fillOpacity: 0,
                fillColor: '#CCF3FF',
                strokeColor: '#CC66CC' // level>1 ? '#CC66CC' : 'red'
            });
        }
    }

    drawMap();
    function drawMap(){


    }



</script>

</body>
</html>
